
const net = require('net')

const socket = new net.Socket()

const port = 6666
const hostname = '10.50.39.194'

socket.setEncoding='utf-8'

socket.connect(port,hostname,()=>{
    console.log("连接服务器成功");
    //发送心跳
    setInterval(()=>{
       socket.write("ping ~")
    },3000);
})

socket.on('data',(msg)=>{
    console.log(msg);
})

socket.on('close',()=>{
    console.log("远程服务器已经断开连接");
})

